package com.ssfGame.puremvc.controller.load
{
	
	import com.ssfGame.puremvc.StaticConst;
	import com.ssfGame.puremvc.model.vo.ConfigVO;
	import com.ssfGame.puremvc.model.vo.LoadVO;
	import com.ssfGame.puremvc.view.module.queueload.vo.QueueLoadVO;
	import com.ssfGame.puremvc.view.module.queueload.vo.ShowLoadVO;
	
	import flash.display.DisplayObject;
	import flash.display.LoaderInfo;
	
	import flashx.textLayout.elements.BreakElement;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	/**
	 * 加载游戏基础数据
	 * @author chery
	 */
	public class LoadCommCommand extends SimpleCommand
	{
		private var _configVO:ConfigVO ;
		public function LoadCommCommand()
		{
			super();
		}
		override public function execute(notification:INotification):void{
			_configVO=StaticConst.configVO;
			var tempQueueLoadVO:QueueLoadVO=new QueueLoadVO();
			tempQueueLoadVO.showLoadVO=new ShowLoadVO(StaticConst.N_M_QUEUE_LOAD_BIG_SHOW);
			tempQueueLoadVO.loadVec.push(StaticConst.getLoadVO(_configVO.API_SWF.TYPE,_configVO.API_SWF.URL,StaticConst.load_media_clew));
			for(var i:int=0;i<_configVO.COMMLOADER.length;i++){
				tempQueueLoadVO.loadVec.push(StaticConst.getLoadVO(_configVO.COMMLOADER[i].TYPE,StaticConst.RESOURCE_URL+_configVO.COMMLOADER[i].URL,StaticConst.load_media_clew,2));
			}
			
			tempQueueLoadVO.callBakcFun=onComplete;
			sendNotification(StaticConst.N_C_LOAD,tempQueueLoadVO);
		}
		
		private function onComplete(qVO:QueueLoadVO):void{
			for(var n:int=0;n<qVO.loadVec.length;n++){
				initLoadVO(qVO.loadVec[n]);
			}
			var _loaderInfo:LoaderInfo=qVO.loadVec[0].loaderInfo;
			StaticConst.apiCore.setAPI(_loaderInfo);
			sendNotification(StaticConst.N_M_API_LAYER_ADD,_loaderInfo.content as DisplayObject);
			sendNotification(StaticConst.N_M_QUEUE_LOAD_PANEL_DEL);
			sendNotification(StaticConst.N_C_SHOW_LOGO_MOVIE);
			//
		}
		
		private function initLoadVO(loadVO:LoadVO):void{
			switch(loadVO.url){
			
			}
			
			
		}
		
	}
}